const { ccclass, property } = cc._decorator;

import s from "./EventMgr"
import c from "./MatchGameEventType"
import u from "./frameworkManager"
import p from "./EngineUtil"
import d from "./TimeUtils"
import h from "./MatchGameConfig"
import f, { ObstacleAllType, ObstacleAllType1, SpecifyColor } from "./ObstacleConfig"
import g from "./MatchGameAudioMgr"
import y from "./MatchGameDataMgr"
import m from "./SquareStatusMgr"
import _ from "./MatchItemCtrl"
import v from "./ObstacleCtrl"
import b from "./SquareItem"
import C from "./UiManage"
import T from "./MatchGameUtilsDataMgr"
import M from "./multiObstaclePrefab"
import P from "./ObstacleAniCtrl"
import S from "./CandleboxPrefab"
import w from "./ColorBottlePrefab"
import A from "./CupboardPlatePrefab"
import O from "./cupHolderPrefab"
import I from "./CurtainPrefab"
import N from "./DrillFill"
import E from "./MatchGameCenterCtrl"
import SquareItem from "./SquareItem";
import UiManager from "./UiManage";
import MatchGameConfig from "./MatchGameConfig";
import MatchGameCenterCtrl from "./MatchGameCenterCtrl";

@ccclass
export default class MultiObstaclePrefabCtrl extends SquareItem {

    public itemInfo = null;
    public emptyObstacleArr = [];
    public curtainNode = null;
    public cupboardPlateNode = null;
    public colorBottleNode = null;
    public candleBoxNode = null;
    public DrillFillNode = null;
    public safeBox = null;
    public isClearAll = false;
    public colorBottleInfo = [];
    public duringShortIci = false;
    public iciAniCount = 0;
    public drillDirection = -1;
    public candleInfo = [];
    public cupHolderInfo = [];
    public cupHolderItems = [];
    public ui;
    public onLoad() {
        this.onUILoad();
        this.addButtonListen();
    };
    public start() { };
    public onUILoad() {
        this.ui = this.node.addComponent(M);
    };
    public addButtonListen() { };
    public initData() { };
    public _couldTouch;
    public drillFillNode;
    public init(t, a, o) {
        this.emptyObstacleArr = [];
        this.squareType = h.SquareType.ObstacleItem;
        this.itemInfo = o;
        this.canMove = !1;
        this._couldTouch = !1;
        this.curtainNode = null;
        this.cupboardPlateNode = null;
        this.colorBottleNode = null;
        this.safeBox = null;
        this.drillFillNode = null;
        this.candleBoxNode = null;
        this.isClearAll = !1;
        this.node.getChildByName("emptyItems").removeAllChildren();
        this.node.getChildByName("emptyItems").active = !0;
        super.init(t, a, h.SquareType.ObstacleItem, this.itemInfo.ObstacleAllType, this.itemInfo);
        this.layerType = this.itemInfo.LayoutType;
        this.itemInfo.name != ObstacleAllType1.CBD ? this.itemInfo.name != ObstacleAllType1.ICI && (this.itemInfo.name != ObstacleAllType1.CUR ? this.itemInfo.name != ObstacleAllType1.SAF ? this.itemInfo.name != ObstacleAllType1.GLD ? this.itemInfo.name != ObstacleAllType1.BNT || this.initBirdNest() : this.initGrassLand() : this.initSafeBox() : this.initCurtain()) : this.initCupboardPlate();
    };
    public getPathStr() {
        var e;
        this.itemInfo.name == ObstacleAllType1.GLD ? e = this.itemInfo.name + "_" + this.itemInfo.Hp : this.itemInfo.name == ObstacleAllType1.CBO ? e = this.itemInfo.name + "_Bg" : this.itemInfo.name == ObstacleAllType1.SAF ? e = this.itemInfo.name + "_" + this.itemInfo.Hp : this.itemInfo.name == ObstacleAllType1.CBD && (e = 11 == this.itemInfo.Hp ? this.itemInfo.name + "_close" : this.itemInfo.name + "_open");
        return e;
    };
    public async initBottleInfo(e: number[], t: boolean = false): Promise<void> {
        this.colorBottleInfo = [];
        let o: cc.Node;
        if (!t) {
            o = cc.instantiate(MatchGameCenterCtrl._instance.colorBottle);
        } else {
            let o1 = await UiManager.loaderPrefabInDeepPath("prefabs/MatchGame/ObstaclePrefab/ColorBottle");
            o = cc.instantiate(o1);
        }
        o.parent = this.node.getChildByName("emptyItems");
        o.name = "ColorBottle";
        this.colorBottleNode = o;
        const n = this.colorBottleNode.getComponent(w);
        n.bottleParent.removeAllChildren();
        n.bottomSpine.active = true;
        n.bottomSpine.getComponent(sp.Skeleton).setAnimation(0, "idle_1", false);
        if (t) {
            const c = this;
            for (let p = 0; p < e.length; p++) {
                c.colorBottleInfo.push({
                    index: p,
                    color: Number(e[p]),
                    finish: false
                });
                const t = new cc.Node("bottle_" + p);
                t.addComponent(cc.Sprite);
                T.loadImage(
                    "imgs/game/obstacle/ColorBottle_Item_" + e[p],
                    t.getComponent(cc.Sprite),
                    () => {
                        t.width = 56;
                        t.height = 70;
                    },
                    () => {
                        u.error("加载图片报错---");
                    }
                );
                t.parent = c.node.getChildByName("emptyItems");
                switch (p) {
                    case 0:
                        t.x = 46;
                        t.y = -50;
                        break;
                    case 1:
                        t.x = 106;
                        t.y = -50;
                        break;
                    case 2:
                        t.x = 46;
                        t.y = -105;
                        break;
                    case 3:
                        t.x = 106;
                        t.y = -105;
                        break;
                }
            }
        } else {
            for (let p = 0; p < this.emptyObstacleArr.length; p++) {
                this.colorBottleInfo.push({
                    index: p,
                    color: Number(e[p]),
                    finish: false
                });
                const d = cc.instantiate(n.bottle);
                d.parent = n.bottleParent;
                const f = this.emptyObstacleArr[p]._row;
                const g = this.emptyObstacleArr[p]._col;
                // d.x = 46 + (this._row == g ? 0 : 60);
                // d.y = (this._col == g ? 0 : -55) - 50;
                if (p == 0) {
                    d.x = -60;
                    d.y = 50;
                } else if (p == 1) {
                    d.x = 0;
                    d.y = 50;
                } else if (p == 2) {
                    d.x = -60;
                    d.y = -24;
                } else if (p == 3) {
                    d.x = 0;
                    d.y = -24;
                }
                let m = "";
                switch (Number(e[p])) {
                    case h.MatchItemType.blueShield:
                        m = "YaoPing_Lan";
                        break;
                    case h.MatchItemType.greenLeaf:
                        m = "YaoPing_Lv";
                        break;
                    case h.MatchItemType.purpleGem:
                        m = "YaoPing_Zi";
                        break;
                    case h.MatchItemType.redBook:
                        m = "YaoPing_Hong";
                        break;
                    case h.MatchItemType.yellowCrown:
                        m = "YaoPing_Huang";
                        break;
                }
                d.getComponent(sp.Skeleton).setSkin(m);
                d.getComponent(sp.Skeleton).setAnimation(0, "idle_2", false);
                d.name = "bottle_" + p;
            }
        }
    }


    public initDrill(e: any, t: boolean = false): void {
        this.drillDirection = e;
        console.error("钻头初始化", e);
        let drillFillPrefab;
        if (E._instance) {
            drillFillPrefab = cc.instantiate(E._instance.drillFillPrefab);
        } else {
            drillFillPrefab = cc.instantiate(UiManager.loaderPrefabInDeepPath("prefabs/DrillFill"));
        }
        drillFillPrefab.parent = this.node.getChildByName("emptyItems");
        drillFillPrefab.name = "DrillFill";
        this.DrillFillNode = drillFillPrefab;
        const NComponent = this.DrillFillNode.getComponent(N);
        NComponent.initDrill(this.drillDirection, this.itemInfo.Hp, this.itemInfo.SpecifyColor);
    }
    public clearOneDrill(e) {
        var t = this, a = e.itemType, o = cc.v3(this.node.x, this.node.y);
        this.itemInfo.name == ObstacleAllType1.DRI && a == this.itemInfo.SpecifyColor && this.DrillFillNode && P.playDrillFlyAni({
            row: e._row,
            col: e._col
        }, o, a, function () {
            var e = t.DrillFillNode.getComponent(N);
            if (!(t.itemInfo.Hp <= 0)) {
                t.itemInfo.Hp -= 1;
                t.itemInfo.Hp <= 0 ? t.clearAllDrill() : e.onclearOne(t.itemInfo.Hp);
            }
        });
    };
    public clearAllDrill() {
        var e = this;
        this.itemInfo.Hp = 0;
        this.scheduleOnce(function () {
            y.clearDrill({
                row: e._row,
                col: e._col
            }, e.drillDirection);
            E._instance.recoverSquare(e);
        }, .5);
        this.playDrillAni();
    };
    public playDrillAni() {
        var e;
        (e = cc.instantiate(E._instance.drillFillPrefab)).name = "DrillFill";
        this.DrillFillNode.getComponent(N).initDrill(this.drillDirection, 0, this.itemInfo.SpecifyColor);
        P.playDrillDestoryAni({
            row: this._row,
            col: this._col
        }, this.drillDirection, e, this.itemInfo.SpecifyColor, function () { });
    };
    public async initCandleBox(e: number[], t: boolean = false): Promise<void> {
        this.candleInfo = [];
        let candleboxPrefab;
        if (E._instance) {
            candleboxPrefab = E._instance.candleboxPrefab;
        } else {
            const prefab = await UiManager.loaderPrefabInDeepPath("prefabs/Candlebox");
            candleboxPrefab = cc.instantiate(prefab);
        }
        const candleboxNode = cc.instantiate(candleboxPrefab);
        candleboxNode.parent = this.node.getChildByName("emptyItems");
        candleboxNode.name = "Candlebox";
        this.candleBoxNode = candleboxNode;
        this.candleBoxNode.getComponent(S);
        for (let a = 0; a < e.length; a++) {
            this.candleInfo.push({
                index: a,
                status: 1,
                color: Number(e[a])
            });
        }
        const hp = this.getCandleBoxHp();
        this.itemInfo.Hp = hp;
        u.log("蜡烛盒子初始化", this.candleInfo);
        this.setAllCandleAni(1);
    }
    public setAllCandleAni(e) {
        var t = this.candleBoxNode.getComponent(S);
        if (0 != this.itemInfo.enable) {
            for (a = 0; a < this.candleInfo.length; a++) this.setOneCandleAni(t.candleNodes[a], e, this.candleInfo[a].color);
            this.playCandleBottomAni(1);
        } else for (var a = 0; a < this.candleInfo.length; a++) t.candleNodes[a].getComponent(sp.Skeleton).setAnimation(0, "idle_5", true);
    };
    public clearOneCandle(e) {
        var t = this;
        if (0 != this.itemInfo.enable) {
            g.playCandleBoxShakeAudio();
            this.scheduleOnce(function () {
                g.playCandleBoxShake2Audio();
            }, .2);
            u.log("clearOneCandle", e);
            if (this.candleInfo[e] && 1 == this.candleInfo[e].status) {
                this.candleInfo[e].status = -1;
                this.playOneCandleDestory(this.candleInfo[e]);
                this.playAllCandleShake();
                this.scheduleOnce(function () {
                    var e = t.getCandleBoxHp();
                    t.itemInfo.Hp = e;
                    v.updateObstacleTargetCount(ObstacleAllType.Candlebox);
                    e <= 0 && t.clearAllCandle();
                }, .8);
            } else u.log("消除单个蜡烛报错了~~~", e);
        }
    };
    public clearAllCandle(e?) {
        var t = this;
        void 0 == e && (e = false);
        if (0 != this.itemInfo.enable) {
            this.itemInfo.enable = false;
            this.playCandleDewstoryAni();
            g.playCandleFuseAudio();
            g.playCandleBlipAudio();
            this.playCandleBottomAni(3, function () {
                g.playCandleExplodeAudio();
                y.clearAllNormalSquare();
                E._instance.recoverSquare(t);
                P.playCandleDestoryEffectAni({
                    row: t._row,
                    col: t._col
                }, t.itemInfo, function () { });
            });
            this.itemInfo.enable = false;
        }
    };
    public setOneCandleAni(e, t, a) {
        var o;
        o = 1 != t && 2 != t && 3 != t;
        var i = "Lv";
        a == SpecifyColor.greenLeaf ? i = "Lv" : a == SpecifyColor.redBook ? i = "Hong" : a == SpecifyColor.yellowCrown ? i = "Huang" : a == SpecifyColor.blueShield && (i = "Lan");
        e.getComponent(sp.Skeleton).setSkin(i);
        var r = "idle_" + t;
        e.getComponent(sp.Skeleton).setAnimation(0, r, o);
    };
    public playOneCandleDestory(e) {
        for (var t = this.candleBoxNode.getComponent(S), a = 0; a < this.candleInfo.length; a++) if (a == e.index) {
            var o = t.candleNodes[a].getComponent(sp.Skeleton);
            o.setAnimation(0, "idle_3", false);
            o.addAnimation(0, "idle_4", true);
        }
    };
    public playAllCandleShake() {
        for (var e = this.candleBoxNode.getComponent(S), t = 0; t < this.candleInfo.length; t++) if (1 == this.candleInfo[t].status) {
            var a = e.candleNodes[t].getComponent(sp.Skeleton);
            a.setAnimation(0, "idle_2", false);
            a.addAnimation(0, "idle_1", false);
        }
        this.playCandleBottomAni(2, function () { });
    };
    public playCandleDewstoryAni() {
        for (var e = this.candleBoxNode.getComponent(S), t = 0; t < this.candleInfo.length; t++) this.setOneCandleAni(e.candleNodes[t], 5, this.candleInfo[t].color);
    };
    public playCandleBottomAni(e, t?) {
        var a = "idle_" + e, o = this.candleBoxNode.getComponent(S).bottomNode.getComponent(sp.Skeleton);
        o.setAnimation(0, a, false);
        o.setCompleteListener(function () {
            t && t();
        });
    };
    public clearCandleBoxByNeighborArr(e) {
        u.log("clearCandleBoxByNeighborArr", e);
        if (e && e.length) for (var t = 0; t < e.length; t++) {
            var a = e[t];
            if (a.squareType == h.SquareType.MatchItem) for (var o = 0; o < this.candleInfo.length; o++) if (1 == this.candleInfo[o].status && this.candleInfo[o].color == a.itemType) {
                this.clearOneCandle(o);
                u.log("this.clearOneCandle(j)", o);
                return;
            }
        } else u.log("没有蜡烛盒子可以销毁");
    };
    public celarCandleBoxByEmptyItem(e) {
        if (e && e.length) {
            for (var t = 0; t < this.candleInfo.length; t++) if (1 == this.candleInfo[t].status) {
                this.clearOneCandle(t);
                break;
            }
        } else u.log("没有蜡烛盒子可以销毁2");
    };
    public getCandleBoxHp() {
        for (var e = 0, t = 0; t < this.candleInfo.length; t++) 1 == this.candleInfo[t].status && (e += 1);
        u.log("getCandleBoxHp---", e);
        return e;
    };
    public forceClearAllCandle() {
        for (var e = this, t = 0; t < this.candleInfo.length; t++) if (1 == this.candleInfo[t].status) {
            this.playOneCandleDestory(this.candleInfo[t]);
            this.candleInfo[t].status = -1;
        }
        this.scheduleOnce(function () {
            e.itemInfo.Hp = 0;
            e.clearAllCandle();
            v.updateObstacleTargetCount(ObstacleAllType.Candlebox);
        }, .8);
    };
    public async initCupHolder(e: string): Promise<void> {
        let t: cc.Prefab;
        let t1;
        if (E._instance) {
            t = cc.instantiate(E._instance.cupHolderPrefab);
        } else {
            t = await UiManager.loaderPrefabInDeepPath("prefabs/cupHolderPrefab");
            t1 = cc.instantiate(t);
        }
        this.cupHolderInfo = [];
        const a = e.split("&");
        for (let o = 0; o < a.length; o++) {
            const i = a[o].split("~");
            this.cupHolderInfo.push({
                row: Number(i[0]),
                col: Number(i[1]),
                status: 1
            });
        }
        this.itemInfo.Hp = this.getCupHp();
        u.log("创建杯架空障碍物地点集合-----", this.cupHolderInfo);
        await this.createCupHolderBottomShow(t1);
    }

    async createCupHolderBottomShow(prefab: cc.Prefab): Promise<void> {
        this.cupHolderItems = [];
        const e = this.node.getChildByName("emptyItems");
        for (let t = 0; t < this.cupHolderInfo.length; t++) {
            let a;
            if (E._instance) {
                a = cc.instantiate(E._instance.cupHolderPrefab);
            } else {
                a = cc.instantiate(prefab);
            }
            a.parent = e;
            a.getComponent(O).showSide(this.cupHolderInfo[t].row, this.cupHolderInfo[t].col, this.cupHolderInfo);
            this.cupHolderItems.push(a.getComponent(O));
        }
    }
    public clearCupEmptyItems(e) {
        for (var t = [], a = 0; a < e.length; a++) {
            var o = e[a];
            if (o.itemInfo.enable) {
                o.itemInfo.enable = false;
                for (var i = 0; i < this.cupHolderInfo.length; i++) this.cupHolderInfo[i].row == o._row && this.cupHolderInfo[i].col == o._col && this.cupHolderInfo[i].status > 0 && t.push(i);
            }
        }
        u.log("cupIndexArr-----", t);
        this.clearCups(t);
    };
    public clearCups(e) {
        if (e.length) {
            for (var t = 0; t < e.length; t++) {
                var a = e[t];
                this.cupHolderInfo[a].status = -1;
                this.cupHolderItems[a].playDestoryAni();
                P.playCupDestoryEffectAni({
                    row: this.cupHolderInfo[a].row,
                    col: this.cupHolderInfo[a].col
                }, this.itemInfo, null);
            }
            this.itemInfo.Hp = this.getCupHp();
            u.log(" this.itemInfo.Hp---", this.itemInfo.Hp, this.cupHolderInfo);
            this.itemInfo.Hp <= 0 ? this.destoryCupHolder() : this.playShakeCupAni();
            v.updateObstacleTargetCount(ObstacleAllType.CupHolder);
        }
    };
    public playShakeCupAni() {
        for (var e = 0; e < this.cupHolderInfo.length; e++) this.cupHolderInfo[e].status > 0 && this.cupHolderItems[e].playShakeAni();
    };
    public getCupHp() {
        for (var e = 0, t = 0; t < this.cupHolderInfo.length; t++) this.cupHolderInfo[t].status > 0 && e++;
        return e;
    };
    public destoryCupHolder() {
        var e = this;
        this.cupHolderInfo.forEach((e) => {
            P.playCupHolderDestoryEffectAni({
                row: e.row,
                col: e.col
            }, null, null);
        });
        g.playCupHolderBreakAudio();
        this.node.getChildByName("emptyItems").removeAllChildren();
        this.scheduleOnce(function () {
            E._instance.recoverSquare(e);
        }, 1);
    };
    public clearAllCups() {
        for (var e = 0; e < this.cupHolderInfo.length; e++) if (this.cupHolderInfo[e].status > 0) {
            this.cupHolderInfo[e].status = -1;
            this.cupHolderItems[e].playDestoryAni();
            P.playCupDestoryEffectAni({
                row: this.cupHolderInfo[e].row,
                col: this.cupHolderInfo[e].col
            }, this.itemInfo, null);
        }
        this.itemInfo.Hp = 0;
        u.log(" this.itemInfo.Hp---", this.itemInfo.Hp, this.cupHolderInfo);
        this.destoryCupHolder();
        v.updateObstacleTargetCount(ObstacleAllType.CupHolder);
    };
    public async initCupboardPlate(): Promise<void> {
        let e: cc.Prefab;
        let e1;
        if (E._instance) {
            e1 = cc.instantiate(E._instance.cupboardPlate);
        } else {
            e = await UiManager.loaderPrefabInDeepPath("prefabs/CupboardPlate");
            e1 = cc.instantiate(e);
        }

        e1.parent = this.node.getChildByName("emptyItems");
        this.cupboardPlateNode = e1;

        const t = this.cupboardPlateNode.getComponent(A);
        e1.position = cc.v3();
        e1.active = true;

        e1.children.forEach((child) => {
            child.active = true;
        });

        e1.name = "CupboardPlate";
        t.plateParent.active = false;
        t.bottomSpine.getComponent(sp.Skeleton).setAnimation(0, "idle_1", false);
        t.doorSpine.active = true;
        t.doorSpine.getComponent(sp.Skeleton).setAnimation(0, "idle_1", false);
    }

    public async initIcicle(e: number): Promise<void> {
        try {
            this.duringShortIci = false;
            let t: cc.Prefab;
            let t1;
            if (E._instance) {
                t1 = cc.instantiate(E._instance.icicle);
            } else {
                t = await UiManager.loaderPrefabInDeepPath("prefabs/Icicle");
                t1 = cc.instantiate(t);
            }

            t1.parent = this.node.getChildByName("emptyItems");
            t1.active = this.itemInfo.Hp <= 11;
            t1.name = "Icicle";

            t1.children.forEach((child) => {
                child.active = true;
            });

            if (e == 0) {
                t1.angle = 90;
                // t1.x = 38;
                // t1.y = -78;
            } else if (e == 1) {
                t1.angle = 0;
                // t1.x = 0;
                // t1.y = -38;
            } else if (e == 2) {
                t1.angle = -90;
                // t1.x = 38;
                // t1.y = 0;
            } else if (e == 3) {
                t1.angle = 180;
                // t1.x = 78;
                // t1.y = -38;
            }

            const a = this.itemInfo.Hp;
            t1.getChildByName("mask").getChildByName("Pillar").x = 78 * (a - 1) - 769 - 11;
            t1.getChildByName("base").getComponent(sp.Skeleton).setAnimation(0, "idle_1", false);

            this.iciAniCount = 0;
        } catch (error) {
            console.error(error);
        }
    }

    public async initSafeBox(): Promise<void> {
        try {
            let e: cc.Prefab;
            let e1
            if (E._instance) {
                e1 = cc.instantiate(E._instance.safeBoxPrefab);
            } else {
                e = await UiManager.loaderPrefabInDeepPath("prefabs/SafeBox");
                e1 = cc.instantiate(e);
            }

            e1.parent = this.node.getChildByName("emptyItems");
            e1.name = "SafeBox";
            this.safeBox = e1;

            const t = e1.getChildByName("spine");
            t.active = true;
            t.getComponent(sp.Skeleton).setAnimation(
                0,
                "idle_" + (6 - this.itemInfo.Hp),
                false
            );
        } catch (error) {
            console.error(error);
        }
    }
    public async initBirdNest(): Promise<void> {
        let e;
        if (!E._instance) {
            e = await cc.instantiate(UiManager.loaderPrefabInDeepPath("prefabs/MatchGame/ObstaclePrefab/BirdNest"));
        } else {
            e = cc.instantiate(E._instance.birdNestPrefab);
        }
        e.parent = this.node.getChildByName("emptyItems");
        e.name = "BirdNest";
        u.log("initBirdNest");
    }

    public async initGrassLand(): Promise<void> {
        let e;
        if (!E._instance) {
            e = await cc.instantiate(UiManager.loaderPrefabInDeepPath("prefabs/GrassLand"));
        } else {
            e = cc.instantiate(E._instance.grassLandPrefab);
        }
        e.parent = this.node.getChildByName("emptyItems");
        e.name = "GrassLand";
        this.safeBox = e;
        let t = e.getChildByName("spine");
        t.active = true;
        t.getComponent(sp.Skeleton).setAnimation(0, "idle_1", false);
    }

    public async initCurtain(): Promise<void> {
        const itemInfo = this.itemInfo;
        const t = itemInfo.FloorArea.width;
        const a = itemInfo.FloorArea.height;
        const o = itemInfo.SpecifyColor;

        let i: cc.Node;
        if (E._instance) {
            i = cc.instantiate(E._instance.curtain);
        } else {
            let i1 = await UiManager.loaderPrefabInDeepPath("prefabs/MatchGame/ObstaclePrefab/Curtain");
            i = cc.instantiate(i1);
        }

        i.parent = this.node.getChildByName("emptyItems");
        i.name = "Curtain";
        this.curtainNode = i;

        const r = this.curtainNode.getComponent(I);
        const n = r.curtain_bg;
        n.children.forEach((e: cc.Node) => {
            e.active = false;
        });

        const s = r.curtain_bg_copy;
        s.position = cc.v3();
        s.removeAllChildren();
        s.y = 0;

        const c = r.curtain_top;
        c.removeAllChildren();

        const u = r.curtain_line;
        u.y = 120 - (a - 1) * h.ITEM_HEIGHT - h.ITEM_HEIGHT;
        if (u.y < 0) {
            u.y = 0;
        }

        const p = r.curtain_item;
        p.active = true;
        UiManager.loadSpriteFrameInDeepPath(p.getComponent(cc.Sprite), "imgs/game/obstacle/curtain_item_" + o);

        const d = r.curtain_line_mask;
        d.x = h.ITEM_WIDTH * t / 2 - h.ITEM_WIDTH / 2;
        d.width = (h.ITEM_WIDTH + 1) * t;
        d.height = (h.ITEM_HEIGHT + 1) * a + h.ITEM_HEIGHT * 4;
        s.x = -d.x;
        c.x = -d.x;

        this.setCurtainLeftCount(0);

        const f = n.getChildByName("curtain_top_1");
        const g = n.getChildByName("curtain_top_2");
        const y = n.getChildByName("curtain_top_3");
        const m = n.getChildByName("curtain_middle_1");
        const _ = n.getChildByName("curtain_middle_2");
        const v = n.getChildByName("curtain_middle_3");
        const b = n.getChildByName("curtain_bottom_1");
        const T = n.getChildByName("curtain_bottom_2");
        const M = n.getChildByName("curtain_bottom_3");

        const P = (e: number, o: number): cc.Node => {
            let n: cc.Node = null;
            if (e === 0) {
                if (o === 0) {
                    n = cc.instantiate(f);
                } else if (o === a - 1) {
                    n = cc.instantiate(b);
                } else {
                    n = cc.instantiate(m);
                }
            } else if (e === t - 1) {
                if (o === 0) {
                    n = cc.instantiate(y);
                } else if (o === a - 1) {
                    n = cc.instantiate(M);
                } else {
                    n = cc.instantiate(v);
                }
            } else {
                if (o === 0) {
                    n = cc.instantiate(g);
                } else if (o === a - 1) {
                    n = cc.instantiate(T);
                } else {
                    n = cc.instantiate(_);
                }
            }

            const i = (e === 0 && o === a - 1) ? 0 : (e === 0 ? 0 : 78 * e);
            const r = 90 * -o ;

            n.parent = (o === 0 ? c : s);
            n.active = true;
            n.name = "item_" + e + "_" + o;
            n.position = cc.v3(i, r);
            return n;
        };

        for (let S = 0; S < t; S++) {
            for (let w = 0; w < a; w++) {
                P(S, w);
            }
        }
    }

    public clearGrassLand(e?) {
        void 0 == e && (e = false);
        e ? this.itemInfo.Hp = 0 : this.itemInfo.Hp -= 1;
        var t = this.node.getChildByName("emptyItems")?.getChildByName("GrassLand")?.getChildByName("spine");
        if (m.getSquareNormalStatus(this)) {
            P.playObstacleEffectAni({
                row: this._row,
                col: this._col
            }, this.itemInfo, function () { });
            g.playObstacleEffectAUdio(this.itemInfo);
        }
        if (this.itemInfo.Hp > 0) {
            P.playObstacleAni(this.itemInfo, t);
            this.setEmptyNormal();
        } else E._instance.recoverSquare(this);
    };
    public setEmptyNormal() {
        this.emptyObstacleArr.forEach((e) => {
            m.setNormalByDestory(e);
        });
    };
    public clearBirdNest() {
        this.itemInfo.Hp -= 1;
        u.log("清除鸟巢==", this.itemInfo.Hp);
        if (this.itemInfo.Hp > 0) {
            p.GetChildByName(this.node, "bottom", true);
            var e = p.GetChildByName(this.node, "doorSpine", true);
            if (e) {
                var t = e.getComponent(sp.Skeleton);
                switch (this.itemInfo.Hp) {
                    case 4:
                        p.GetChildByName(this.node, "egg_3", true).active = true;
                        t.setAnimation(0, "idle_2", false);
                        g.playBirdNestAudio(1);
                        break;

                    case 3:
                        for (var a = 0; a < 3; a++) if (o = p.GetChildByName(this.node, "egg_" + (a + 1), true)) {
                            o.active = true;
                            o.getComponent(sp.Skeleton).setAnimation(0, "idle_1", true);
                        }
                        t.setAnimation(0, "idle_3", false);
                        g.playBirdNestAudio(2);
                        break;

                    case 2:
                        for (a = 0; a < 3; a++) {
                            var o;
                            if (o = p.GetChildByName(this.node, "egg_" + (a + 1), true)) {
                                o.active = true;
                                o.getComponent(sp.Skeleton).setAnimation(0, "idle_4", true);
                            }
                        }
                        t.setAnimation(0, "idle_3", false);
                        g.playBirdNestAudio(3);
                        break;

                    case 1:
                        var i = (e) => {
                            var t = p.GetChildByName(r.node, "egg_" + (e + 1), true);
                            if (t) {
                                t.active = true;
                                t.getComponent(sp.Skeleton).setAnimation(0, "idle_5", false);
                                t.getComponent(sp.Skeleton).setCompleteListener(function () {
                                    var e = "";
                                    switch (p.getRandomNumber(1, 4)) {
                                        case 1:
                                            e = "lookOn";
                                            break;

                                        case 2:
                                            e = "idle_5";
                                            break;

                                        case 3:
                                            e = "lookOn_R";
                                            break;

                                        case 4:
                                            e = "lookOn_L";
                                    }
                                    t.getComponent(sp.Skeleton).setAnimation(0, "" + e, false);
                                });
                            }
                        }, r = this;
                        for (a = 0; a < 3; a++) i(a);
                        t.setAnimation(0, "idle_3", false);
                        g.playBirdNestAudio(4);
                }
            }
        } else {
            this.itemInfo.Hp = 0;
            P.playObstacleEffectAni({
                row: this._row,
                col: this._col
            }, this.itemInfo, function () { });
            g.playBirdNestAudio(5);
            E._instance.recoverSquare(this);
            v.createBirdMatchItem(this._row, this._col);
        }
    };
    public celarAllBirdNest() {
        this.itemInfo.Hp = 0;
        P.playObstacleEffectAni({
            row: this._row,
            col: this._col
        }, this.itemInfo, function () { });
        g.playBirdNestAudio(5);
        E._instance.recoverSquare(this);
        v.createBirdMatchItem(this._row, this._col);
    };
    public clearCurtain(e) {
        var t = this, a = e.itemType;
        if (this.itemInfo.name == ObstacleAllType1.CUR && a == this.itemInfo.SpecifyColor && this.curtainNode) {
            var o = this.curtainNode.getComponent(I), i = o.left_count, r = o.curtain_item, n = o.curtain_line, l = n.getComponent(sp.Skeleton), s = o.curtain_line_mask, c = o.curtain_bg_copy, u = o.curtain_top;
            if (this.itemInfo.Hp <= 0) return 0;
            this.itemInfo.Hp -= 1;
            g.playCurtainCollectAudio();
            if (this.itemInfo.Hp <= 0) {
                var p = cc.v3(this.node.x + s.x, this.node.y + n.y - 180);
                P.playCurtainFlyAni({
                    row: e._row,
                    col: e._col
                }, p, a, function () {
                    i.getComponent(cc.Label).string = "" + t.itemInfo.Hp;
                    var e = t.itemInfo.FloorArea.height * MatchGameConfig.ITEM_HEIGHT - 60;
                    l.setAnimation(0, "explode_2", false);
                    g.playCurtainBreakAudio();
                    l.setCompleteListener(function () { });
                    cc.tween(c).to(.3 * t.itemInfo.FloorArea.height, {
                        y: e
                    }).call(function () {
                        r.active = false;
                        c.active = false;
                        u.active = false;
                        g.playCurtainDestoryAudio();
                        P.playCurtainDestoryAni({
                            row: t._row,
                            col: t._col
                        }, {
                            w: t.itemInfo.FloorArea.width,
                            h: t.itemInfo.FloorArea.height
                        }, function () {
                            E._instance.recoverSquare(t);
                            g.playCurtainOpenAudio();
                            y.checkCanFill() && y.AllFill();
                            y.checkIsCanEliminate() && y.startEliminate();
                        });
                    }).start();
                    cc.tween(n).to(.3 * t.itemInfo.FloorArea.height, {
                        y: 100
                    }).call(function () { }).start();
                });
            } else {
                p = cc.v3(this.node.x + s.x, this.node.y + n.y - 180);
                P.playCurtainFlyAni({
                    row: e._row,
                    col: e._col
                }, p, a, function () {
                    l.setAnimation(0, "explode_1", false);
                    i.getComponent(cc.Label).string = "" + t.itemInfo.Hp;
                });
            }
        }
    };
    public clearAllCurtain() {
        var e = this, t = this.curtainNode.getComponent(I), a = t.left_count, o = t.curtain_item, i = t.curtain_line, r = i.getComponent(sp.Skeleton), n = t.curtain_line_mask, l = t.curtain_bg_copy, s = t.curtain_top;
        if (this.itemInfo.Hp <= 0) return 0;
        this.itemInfo.Hp = 0;
        g.playCurtainCollectAudio();
        cc.v3(this.node.x + n.x, this.node.y + i.y - 180);
        a.getComponent(cc.Label).string = "" + this.itemInfo.Hp;
        var c = this.itemInfo.FloorArea.height * MatchGameConfig.ITEM_HEIGHT - 60;
        r.setAnimation(0, "explode_2", false);
        g.playCurtainBreakAudio();
        r.setCompleteListener(function () { });
        cc.tween(l).to(.3 * this.itemInfo.FloorArea.height, {
            y: c
        }).call(function () {
            o.active = false;
            l.active = false;
            s.active = false;
            g.playCurtainDestoryAudio();
            P.playCurtainDestoryAni({
                row: e._row,
                col: e._col
            }, {
                w: e.itemInfo.FloorArea.width,
                h: e.itemInfo.FloorArea.height
            }, function () {
                E._instance.recoverSquare(e);
                g.playCurtainOpenAudio();
            });
        }).start();
        cc.tween(i).to(.3 * this.itemInfo.FloorArea.height, {
            y: 100
        }).call(function () { }).start();
    };
    public setCurtainLeftCount(e) {
        this.itemInfo.Hp -= e;
        if (this.itemInfo.Hp <= 0) E._instance.recoverSquare(this); else {
            var t = this.curtainNode.getComponent(I), a = t.left_count;
            t.curtain_line_mask.active = true;
            a.getComponent(cc.Label).string = "" + this.itemInfo.Hp;
        }
    };
    public shortPillar(e?) {
        var t = this;
        void 0 == e && (e = false);
        this.duringShortIci = true;
        this.itemInfo.Hp -= 1;
        u.log("shortPillar", this.itemInfo.Hp);
        var a = this.node.getChildByName("emptyItems").getChildByName("Icicle"), o = a.getChildByName("mask").getChildByName("Pillar"), i = a.getChildByName("base").getComponent(sp.Skeleton);
        i.setAnimation(0, "Revolve", true);
        var r = this.emptyObstacleArr[this.emptyObstacleArr.length - 1];
        if (this.itemInfo.Hp >= 2) {
            var n = 78 * (this.itemInfo.Hp - 1) - 769 - 11;
            P.playShortPillarAni({
                row: this._row,
                col: this._col
            });
            g.playIceCrusherAudio(false);
            cc.tween(o).to(.3, {
                x: n
            }).call(function () {
                v.clearEmptyObstacle(r, t);
                i.setAnimation(0, "idle_1", false);
                if (t.iciAniCount > 0) {
                    t.iciAniCount -= 1;
                    t.shortPillar();
                } else t.duringShortIci = false;
            }).start();
            this.setEmptyNormal();
        } else {
            g.playIceCrusherAudio(false);
            P.playShortPillarAni({
                row: r._row,
                col: r._col
            });
            cc.tween(o).to(.5, {
                x: -775
            }).call(function () {
                i.node.active = false;
                g.playIceBreakAudio();
                P.playIcicleDestoryAni({
                    row: t._row,
                    col: t._col
                }, t.itemInfo, function () { });
                t.duringShortIci = false;
                E._instance.recoverSquare(t);
                s.trigger(c.ADD_ALL_FILL, {
                    callTime: d.getTimestamp(),
                    tTime: 0
                });
            }).start();
        }
    };
    public playPillarAni() {
        if (this.isClearAll) {
            this.iciAniCount = 0;
            this.shortPillar(true);
        } else this.duringShortIci ? this.iciAniCount += 1 : this.shortPillar();
    };
    public setClose() { };
    public setIconNode() {
        var e = this.ui.IconNode;
        e.x = e.width / 2;
        e.y = -e.height / 2;
    };
    public clear() { };
    public moveTo(t, a, o) {
        super.moveTo.call(this, t, a, o);
    };
    public destorySelf() {
        super.destorySelf.call(this);
        this.clear();
        this.node.opacity = 0;
    };
    public playLightAni() {
        this.node.angle = 0;
        cc.tween(this.node).to(.2, {
            angle: 10
        }).to(.2, {
            angle: 0
        }).to(.2, {
            angle: -10
        }).to(.2, {
            angle: 0
        }).start().repeat(5);
    };
    public onEmptyClear(e) {
        var t = this;
        if (!this.isClearAll) {
            u.log("道具空元素消除---", e);
            if (this.itemInfo.name == ObstacleAllType1.GLD) this.clearGrassLand(); else if (this.itemInfo.name == ObstacleAllType1.CBO) {
                if (e.length > 0) {
                    for (var a = 0; a < e.length; a++) if (e[a].itemInfo.enable) {
                        var o = e[a].obsIndex;
                        this.itemInfo.Hp -= 1;
                        if (y.isHaveObstacleInHigherLayout(this.emptyObstacleArr[o])) continue;
                        this.clearOneBottleItem(o);
                        return;
                    }
                    for (a = 0; a < this.colorBottleInfo.length; a++) if (!this.colorBottleInfo[a].finish) {
                        o = this.colorBottleInfo[a].index;
                        if (y.isHaveObstacleInHigherLayout(this.emptyObstacleArr[o])) continue;
                        u.log("消除那个空元素呢？", o);
                        this.itemInfo.Hp -= 1;
                        this.clearOneBottleItem(o);
                        break;
                    }
                }
                if (this.itemInfo.Hp <= 0) {
                    P.playBottleDestoryAni({
                        row: this._row,
                        col: this._col
                    });
                    E._instance.recoverSquare(this);
                }
            } else if (this.itemInfo.name == ObstacleAllType1.SAF) {
                g.playObstacleEffectAUdio(this.itemInfo);
                this.itemInfo.Hp -= 1;
                if (this.itemInfo.Hp > 0) {
                    this.safeBox.getChildByName("spine").active = false;
                    P.playSafeBoxEffectAni({
                        row: this._row,
                        col: this._col
                    }, this.itemInfo, function () {
                        t.safeBox.getChildByName("spine").active = true;
                        t.safeBox.getChildByName("spine").getComponent(sp.Skeleton).setAnimation(0, "idle_" + (6 - t.itemInfo.Hp), false);
                    });
                    this.setEmptyNormal();
                } else {
                    this.itemInfo.Hp = 0;
                    P.playSafeBoxEffectAni({
                        row: this._row,
                        col: this._col
                    }, this.itemInfo, function () { });
                    E._instance.recoverSquare(this);
                }
            } else this.itemInfo.name == ObstacleAllType1.CBD ? this.clearPlates(e) : this.itemInfo.name == ObstacleAllType1.ICI ? this.playPillarAni() : this.itemInfo.name == ObstacleAllType1.BNT ? this.clearBirdNest() : this.itemInfo.name == ObstacleAllType1.CDE ? this.celarCandleBoxByEmptyItem(e) : this.itemInfo.name == ObstacleAllType1.CHD && this.clearCupEmptyItems(e);
        }
    };
    public onEmptyForceClear() {
        u.log("强制消除---");
        if (!this.isClearAll) {
            this.isClearAll = true;
            if (this.itemInfo.name == ObstacleAllType1.GLD) this.clearGrassLand(true); else if (this.itemInfo.name == ObstacleAllType1.CBO) this.clearAllBottles(); else if (this.itemInfo.name == ObstacleAllType1.SAF) {
                g.playObstacleEffectAUdio(this.itemInfo);
                this.itemInfo.Hp = 0;
                P.playSafeBoxEffectAni({
                    row: this._row,
                    col: this._col
                }, this.itemInfo, function () { });
                E._instance.recoverSquare(this);
            } else this.itemInfo.name == ObstacleAllType1.CBD ? this.clearAllPlates() : this.itemInfo.name == ObstacleAllType1.ICI ? this.playPillarAni() : this.itemInfo.name == ObstacleAllType1.BNT ? this.celarAllBirdNest() : this.itemInfo.name == ObstacleAllType1.CDE ? this.forceClearAllCandle() : this.itemInfo.name == ObstacleAllType1.CHD ? this.clearAllCups() : this.itemInfo.name == ObstacleAllType1.CUR && this.clearAllCurtain();
        }
    };
    public propMatchClear(e) {
        for (var t = [], a = [], o = 0; o < this.emptyObstacleArr.length; o++) for (var i = 0; i < e.length; i++) if (this.emptyObstacleArr[o]._row == e[i].row && this.emptyObstacleArr[o]._col == e[i].col) {
            var r = this.emptyObstacleArr[o], n = r._row, l = r._col;
            E._instance.topSquareGrid[n] && E._instance.topSquareGrid[n][l] ? a.push(E._instance.topSquareGrid[n][l]) : t.push(this.emptyObstacleArr[o]);
        }
        u.log("道具消除--", t);
        t.length && this.onEmptyClear(t);
        for (o = 0; o < a.length; o++) v.onClearOneMatch(a[o]._row, a[o]._col);
    };
    public clearBottleItems(e) {
        u.log("合成消除药水", e, this.colorBottleInfo);
        for (var t = 0; t < e.length; t++) if (this.colorBottleInfo[e[t]] && !this.colorBottleInfo[e[t]].finish) {
            if (y.isHaveObstacleInHigherLayout(this.emptyObstacleArr[e[t]])) continue;
            this.itemInfo.Hp -= 1;
            this.clearOneBottleItem(e[t]);
            return;
        }
    };
    public clearOneBottleItem(e) {
        g.playObstacleEffectAUdio(this.itemInfo);
        u.log("clearOneBottleItem", e);
        var t = this.colorBottleNode.getComponent(w);
        if (t && t.bottleParent) {
            var a = t.bottleParent.getChildByName("bottle_" + e);
            if (a) {
                P.playOneBottleDestoryAni({
                    row: this._row,
                    col: this._col
                }, a.position, this.colorBottleInfo[e].color, function () { });
                a.active = false;
                this.colorBottleInfo[e].finish = true;
                this.emptyObstacleArr[e].itemInfo.enable = false;
                if (this.itemInfo.Hp <= 0) {
                    P.playBottleDestoryAni({
                        row: this._row,
                        col: this._col
                    });
                    E._instance.recoverSquare(this);
                } else this.setEmptyNormal();
                v.updateObstacleTargetCount(ObstacleAllType.ColorBottle);
            } else u.error("清除一个药瓶报错");
            for (var o = 0; o < t.bottleParent.children.length; o++) if (t.bottleParent.children[o].active) {
                t.bottleParent.children[o].getComponent(sp.Skeleton).setAnimation(0, "idle_1", false);
                t.bottleParent.children[o].getComponent(sp.Skeleton).setAnimation(1, "idle_2", false);
            }
            t.bottomSpine.getComponent(sp.Skeleton).setAnimation(0, "explode_1", false);
            t.bottomSpine.getComponent(sp.Skeleton).setAnimation(1, "idle_1", false);
        }
    };
    public clearAllBottles() {
        g.playObstacleEffectAUdio(this.itemInfo);
        var e = this.colorBottleNode.getComponent(w);
        if (e && e.bottleParent) for (var t = 0; t < this.colorBottleInfo.length; t++) {
            var a = e.bottleParent.getChildByName("bottle_" + t);
            if (a && a.active) {
                P.playOneBottleDestoryAni({
                    row: this._row,
                    col: this._col
                }, a.position, this.colorBottleInfo[t].color, function () { });
                a.active = false;
                this.colorBottleInfo[t].finish = true;
                this.emptyObstacleArr[t].itemInfo.enable = false;
            } else u.error("清除一个药瓶报错");
        }
        P.playBottleDestoryAni({
            row: this._row,
            col: this._col
        });
        E._instance.recoverSquare(this);
        v.updateObstacleTargetCount(ObstacleAllType.ColorBottle);
    };
    public clearPlates(e) {
        var t = this;
        u.log("clearPlates----消除个数", e.length);
        if (!(this.itemInfo.Hp <= 0)) {
            var a = e.length, o = this.itemInfo.Hp - a, i = [];
            e.forEach((e) => {
                i.push(e.obsIndex);
            });
            var r = this.cupboardPlateNode.getComponent(A);
            r.plateParent.active = true;
            r.bottomSpine.getComponent(sp.Skeleton).setAnimation(0, "explode_1", false);
            r.doorSpine.active = false;
            if (11 == this.itemInfo.Hp) {
                a = 1;
                this.itemInfo.Hp = 10;
                P.playCurboardAni({
                    row: this._row,
                    col: this._col
                }, this.itemInfo);
                g.playCupboardAudio(this.itemInfo.Hp);
                this.setEmptyNormal();
            } else {
                this.itemInfo.Hp = o;
                if (o <= 0) {
                    this.itemInfo.Hp = 0;
                    g.playCupboardAudio(this.itemInfo.Hp);
                    for (var n = 0; n < 4; n++) {
                        var l = r.plateParent.getChildByName("bottom_" + n);
                        this.clearPlate(l);
                    }
                    r.bottomSpine.active = false;
                    P.playCurboardAni({
                        row: this._row,
                        col: this._col
                    }, this.itemInfo, function () { });
                    this.scheduleOnce(function () {
                        E._instance.recoverSquare(t);
                    }, .3);
                    return;
                }
                g.playCupboardAudio(this.itemInfo.Hp);
                this.setEmptyNormal();
                if (9 == o) {
                    var s = Math.random() > .5 ? 0 : 1;
                    this.clearPlate(r.plateParent.getChildByName("top_" + s));
                } else if (8 == o) {
                    this.clearPlate(r.plateParent.getChildByName("top_0"));
                    this.clearPlate(r.plateParent.getChildByName("top_1"));
                } else if (o > 4) {
                    var c = 0;
                    for (n = 0; n < i.length; n++) if (1 == r.plateParent.getChildByName("middle_" + i[n]).active) {
                        c++;
                        this.clearPlate(r.plateParent.getChildByName("middle_" + i[n]));
                    }
                    if (c < i.length) for (n = 0; n < i.length - c; n++) {
                        var p = this.getOnePlateIndex(true);
                        if (p < 0) u.log("橱柜中层消除报错------"); else if (1 == r.plateParent.getChildByName("middle_" + p).active) {
                            c++;
                            this.clearPlate(r.plateParent.getChildByName("middle_" + p));
                            c++;
                        }
                    }
                } else if (4 == o) for (n = 0; n < 4; n++) {
                    l = r.plateParent.getChildByName("middle_" + n);
                    this.clearPlate(l);
                } else {
                    c = 0;
                    this.clearPlate(r.plateParent.getChildByName("top_0")) && c++;
                    this.clearPlate(r.plateParent.getChildByName("top_1")) && c++;
                    for (n = 0; n < 4; n++) {
                        l = r.plateParent.getChildByName("middle_" + n);
                        this.clearPlate(l) && c++;
                    }
                    var d = 0;
                    for (n = 0; n < 4; n++) r.plateParent.getChildByName("bottom_" + n).active && d++;
                    if (d < o) u.log("还没打就少了一个？"); else for (n = 0; n < d - o; n++) {
                        var h = false;
                        e: for (var y = 0; y < i.length; y++) if (r.plateParent.getChildByName("bottom_" + i[y]).active) {
                            r.plateParent.getChildByName("bottom_" + i[y]).active = false;
                            h = true;
                            break e;
                        }
                        if (!h) e: for (var m = 0; m < 4; m++) if (r.plateParent.getChildByName("bottom_" + m).active) {
                            r.plateParent.getChildByName("bottom_" + m).active = false;
                            break e;
                        }
                    }
                    var _ = 0;
                    for (n = 0; n < 4; n++) r.plateParent.getChildByName("bottom_" + n).active && _++;
                    o !== _ && u.log("final-----", o, _);
                }
            }
            v.updateObstacleTargetCount(ObstacleAllType.cupboard);
            this.playPlatIdleAni();
        }
    };
    public clearPlate(e) {
        if (0 != e.active) {
            e.active = false;
            P.playPlateDestoryAni({
                row: this._row,
                col: this._col
            }, e.position, function () { });
            return true;
        }
    };
    public playPlatIdleAni() {
        this.cupboardPlateNode.getComponent(A).plateParent.children.forEach((e) => {
            e.active && e.getComponent(sp.Skeleton).setAnimation(0, "explode_1", false);
        });
    };
    public getOnePlateIndex(e) {
        for (var t = this.cupboardPlateNode.getComponent(A), a = e ? "middle_" : "bottom_", o = 0; o < 4; o++) if (1 == t.plateParent.getChildByName("" + a + o).active) return o;
        return -1;
    };
    public clearAllPlates() {
        var e = this, t = this.cupboardPlateNode.getComponent(A);
        t.plateParent.active = true;
        t.doorSpine.active = false;
        if (11 == this.itemInfo.Hp) {
            P.playCurboardAni({
                row: this._row,
                col: this._col
            }, this.itemInfo);
            g.playCupboardAudio(this.itemInfo.Hp);
            this.setEmptyNormal();
            this.itemInfo.Hp = 0;
        } else {
            this.itemInfo.Hp = 0;
            t.plateParent.children.forEach(function (t) {
                e.clearPlate(t);
            });
            g.playCupboardAudio(this.itemInfo.Hp);
            t.bottomSpine.active = false;
            P.playCurboardAni({
                row: this._row,
                col: this._col
            }, this.itemInfo, function () { });
            this.scheduleOnce(function () {
                E._instance.recoverSquare(e);
            }, .3);
        }
    };
    public setIconImg() {
        var e = this;
        if (this.itemInfo.Hp > 0) T.loadImage("imgs/game/obstacle/" + this.getPathStr(), this.ui.IconNode.getComponent(cc.Sprite), function () {
            e.ui.IconNode.width = MatchGameConfig.ITEM_WIDTH * e.itemInfo.FloorArea.width;
            e.ui.IconNode.height = MatchGameConfig.ITEM_HEIGHT * e.itemInfo.FloorArea.height;
        }, function () {
            u.log("加载图片报错---");
        }); else {
            if (this.itemInfo.name == ObstacleAllType1.CBO) return;
            E._instance.recoverSquare(this);
        }
    };
    public getTargetLeftCount() {
        if (this.itemInfo.name == ObstacleAllType1.GLD) return 1;
        if (this.itemInfo.name == ObstacleAllType1.CBO) return this.itemInfo.Hp;
        if (this.itemInfo.name == ObstacleAllType1.SAF) return 1;
        if (this.itemInfo.name == ObstacleAllType1.CBD) return this.itemInfo.Hp > 10 ? 10 : this.itemInfo.Hp;
        if (this.itemInfo.name == ObstacleAllType1.ICI) return 1;
        if (this.itemInfo.name == ObstacleAllType1.CUR) return _.getMatchItemsByType(this.itemInfo.SpecifyColor).length;
        if (this.itemInfo.name == ObstacleAllType1.CDE) {
            u.log("ObstacleConfig.ObstacleAllType1.CDE-----", this.itemInfo.Hp);
            return this.itemInfo.Hp;
        }
        return this.itemInfo.name == ObstacleAllType1.CHD ? this.itemInfo.Hp : this.itemInfo.name == ObstacleAllType1.BNT ? 3 : void 0;
    };
    public getElimilateItem() {
        if (this.itemInfo.ObstacleAllType == ObstacleAllType.curtain) {
            var e = _.getMatchItemsByType(this.itemInfo.SpecifyColor);
            return e[p.getRandomNumber(0, e.length)];
        }
        u.log("this.emptyObstacleArr", this.emptyObstacleArr);
        for (var t = 0; t < this.emptyObstacleArr.length; t++) if (this.emptyObstacleArr[t].itemInfo.enable) return this.emptyObstacleArr[t];
        return null;
    };
    public getAllElimilateItem() {
        var e = [];
        if (this.itemInfo.ObstacleAllType == ObstacleAllType.curtain) e = _.getMatchItemsByType(this.itemInfo.SpecifyColor); else if (this.itemInfo.ObstacleAllType == ObstacleAllType.DrillFill) e = _.getMatchItemsByType(this.itemInfo.SpecifyColor); else for (var t = 0; t < this.emptyObstacleArr.length; t++) this.emptyObstacleArr[t].itemInfo.enable && e.push(this.emptyObstacleArr[t]);
        return e;
    };
    public propplerMarkItem() {
        for (var e = 0, t = [], a = 0; a < this.emptyObstacleArr.length; a++) {
            e += this.emptyObstacleArr[a].propellerMarkCount;
            this.emptyObstacleArr[a].itemInfo.enable && t.push(this.emptyObstacleArr[a]);
        }
        return e < this.itemInfo.Hp && t.length ? t[p.getRandomNumber(0, t.length)] : null;
    };
    public propplerMarkStatus() {
        for (var e = 0, t = 0; t < this.emptyObstacleArr.length; t++) {
            e += this.emptyObstacleArr[t].propellerMarkCount;
            this.emptyObstacleArr[t].itemInfo.enable && (e += this.emptyObstacleArr[t].propellerMarkCount);
        }
        return e < this.itemInfo.Hp;
    };
    // t.prefabUrl = "assets/resources/prefabs/MatchGame/multiObstaclePrefab";
    // t.className = "MultiObstaclePrefabCtrl";
    // return r([k, D("UI/MatchGame/MultiObstaclePrefabCtrl")], t);
}